package cn.scw.project.system.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.aspectj.lang.annotation.Log;
import cn.scw.framework.aspectj.lang.enums.BusinessType;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.system.domain.netework.bean.SysUserExtractAddReq;
import cn.scw.project.system.domain.netework.bean.SysUserExtractUpdReq;
import cn.scw.project.system.domain.vo.SysUserExtractVo;
import cn.scw.project.system.service.ISysUserExtractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户提现记录Controller
 *
 * @author api
 * @date 2020-05-20
 */
@Api(tags = "提现记录")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH+"/system/extract")
public class SysUserExtractController extends BaseController {
    @Autowired
    private ISysUserExtractService sysUserExtractService;

    @ApiOperation("查询提现记录列表")
    //@PreAuthorize("@ss.hasPermi('system:extract:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) @ApiParam("处理状态（待处理，提现成功，提现失败）") String status) {
        startPage();
        List<SysUserExtractVo> list = sysUserExtractService.selectSysUserExtractList(status);
        return getDataTable(list);
    }

    @ApiOperation("查询用户提现记录列表")
    @GetMapping("/wx/list")
    public TableDataInfo wxlist() {
        startPage();
        List<SysUserExtractVo> list = sysUserExtractService.selectSysUserExtractListByUser();
        return getDataTable(list);
    }

    @ApiOperation("获取用户提现记录详细信息")
    //@PreAuthorize("@ss.hasPermi('system:extract:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysUserExtractService.selectSysUserExtractVoById(id));
    }

    @ApiOperation("新增用户提现记录")
    //@PreAuthorize("@ss.hasPermi('system:extract:add')")
    @Log(title = "用户提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(SysUserExtractAddReq req) {
        return toAjax(sysUserExtractService.insertSysUserExtract(req));
    }

    @ApiOperation("修改用户提现记录")
    //@PreAuthorize("@ss.hasPermi('system:extract:edit')")
    @Log(title = "用户提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(SysUserExtractUpdReq req) {
        return toAjax(sysUserExtractService.updateSysUserExtract(req));
    }

    @ApiOperation("删除用户提现记录")
    //@PreAuthorize("@ss.hasPermi('system:extract:remove')")
    @Log(title = "用户提现记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysUserExtractService.deleteSysUserExtractByIds(ids));
    }
}
